using UnityEngine;

public class LearningCallback : MonoBehaviour
{
	private Learning lObject;

	public bool removeAfterLeaning;

	private void Start()
	{
		if (removeAfterLeaning && settings.learningCompleted)
		{
			BoxCollider component = GetComponent<BoxCollider>();
			if (component != null)
			{
				Object.Destroy(component);
			}
		}
	}

	public void setLearningObject(Learning lobj)
	{
		lObject = lobj;
	}

	private void OnPress(bool isDown)
	{
		if (!isDown)
		{
			return;
		}
		if (lObject != null)
		{
			Invoke("nextItem", lObject.items[lObject.currentItem].delay);
		}
		if (removeAfterLeaning)
		{
			BoxCollider component = GetComponent<BoxCollider>();
			if (component != null)
			{
				Object.Destroy(component);
			}
		}
	}

	public void OnDrag(Vector2 delta)
	{
		OnPress(true);
	}

	private void nextItem()
	{
		if (lObject != null && lObject.items[lObject.currentItem].itemTransform.gameObject.Equals(base.gameObject))
		{
			lObject.nextItem();
		}
	}
}
